package org.cug.validation;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.cug.anno.State;

/**
 * @Author: gongshihao
 * @Date: 2024-05-15-15:35
 * @Description: this is my code
 */
public class StateValidation implements ConstraintValidator<State,String> {
    /**
     *
     * @param s 将来要校验的数据
     * @param constraintValidatorContext
     * @return 返回false，校验不通过；返回true，校验通过
     */
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if(s==null)
        {
            return false;
        }
        if(s.equals("已发布")||s.equals("草稿"))
        {
            return true;
        }
        return false;
    }
}
